import type { FC } from 'react'
import { useState } from 'react'
import { Result, Button } from 'antd'
import { useNavigate } from 'react-router-dom'
import { resetCurrent } from '@/store/art-add-store.ts'

const ArticleResult: FC = () => {
  const navigate = useNavigate()
  // 需要展示的提示文本
  const [title] = useState(() => {
    const msg = sessionStorage.getItem('msg')
    sessionStorage.clear()
    return msg
  })

  const gotoList = () => {
    navigate('/art-list')
    resetCurrent()
  }

  return (
    <Result
      status="success"
      title={title}
      subTitle=""
      extra={[
        <Button type="primary" key="list" onClick={gotoList}>
          去文章列表
        </Button>,
        <Button key="rewrite" onClick={() => resetCurrent()}>
          再写一篇
        </Button>
      ]}
    />
  )
}

export default ArticleResult
